package com.ruoyi.testDeal.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.testDeal.domain.basic.ReportHj;
import com.ruoyi.testDeal.service.IReportHjService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 检测检验环境信息Controller
 * 
 * @author ruoyi
 * @date 2024-03-29
 */
@RestController
@RequestMapping("/testDeal/reportHj")
public class ReportHjController extends BaseController
{
    @Autowired
    private IReportHjService reportHjService;

    /**
     * 查询检测检验环境信息列表
     */
    @PreAuthorize("@ss.hasPermi('testDeal:reportHj:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReportHj reportHj)
    {
        startPage();
        List<ReportHj> list = reportHjService.selectReportHjList(reportHj);
        return getDataTable(list);
    }

    /**
     * 导出检测检验环境信息列表
     */
    @PreAuthorize("@ss.hasPermi('testDeal:reportHj:export')")
    @Log(title = "检测检验环境信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReportHj reportHj)
    {
        List<ReportHj> list = reportHjService.selectReportHjList(reportHj);
        ExcelUtil<ReportHj> util = new ExcelUtil<ReportHj>(ReportHj.class);
        util.exportExcel(response, list, "检测检验环境信息数据");
    }

    /**
     * 获取检测检验环境信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('testDeal:reportHj:query')")
    @GetMapping(value = "/{reportHjId}")
    public AjaxResult getInfo(@PathVariable("reportHjId") Long reportHjId)
    {
        return success(reportHjService.selectReportHjByReportHjId(reportHjId));
    }

    /**
     * 新增检测检验环境信息
     */
    @PreAuthorize("@ss.hasPermi('testDeal:reportHj:add')")
    @Log(title = "检测检验环境信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReportHj reportHj)
    {
        return toAjax(reportHjService.insertReportHj(reportHj));
    }

    /**
     * 修改检测检验环境信息
     */
    @PreAuthorize("@ss.hasPermi('testDeal:reportHj:edit')")
    @Log(title = "检测检验环境信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReportHj reportHj)
    {
        return toAjax(reportHjService.updateReportHj(reportHj));
    }

    /**
     * 删除检测检验环境信息
     */
    @PreAuthorize("@ss.hasPermi('testDeal:reportHj:remove')")
    @Log(title = "检测检验环境信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reportHjIds}")
    public AjaxResult remove(@PathVariable Long[] reportHjIds)
    {
        return toAjax(reportHjService.deleteReportHjByReportHjIds(reportHjIds));
    }
}
